﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;


namespace TestDxfDocument
{
    //2021-2-22 modify
    //参数赋值，data中的字段需小写
    //未使用图层代码去除
    //未使用的方法添加进SocketServer.cs
    //参数字段错误修改
    class MillingCuttersWithArborHoleForIndexableInserts
    {
        public static void ShoulderMillingCutter(Dictionary<string, Object> data)  //方肩铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 30 && soal < 64.75)
                {
                    scale = 4.0;
                }
                else if (sdc < 54 && soal < 86.3)
                {
                    scale = 3.0;
                }
                else if (sdc < 101 && soal < 129.5)
                {
                    scale = 2.0;
                }
                else if (sdc < 148 && soal < 172.6)
                {
                    scale = 1.5;
                }
                else if (sdc < 242 && soal < 259)
                {
                    scale = 1.0;
                }
                else if (sdc < 336 && soal < 345.3)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path= Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub);
            Vector2 v3 = new Vector2(bd / 2, v2.Y);
            Vector2 v5 = new Vector2(dc / 2, -oal + apmx);
            Vector2 v4 = new Vector2(v3.X, v5.Y - (v5.X - v3.X) / Math.Tan(pi / 3));
            Vector2 v6 = new Vector2(v5.X, -oal);
            Vector2 v8 = new Vector2(v5.X - apmx * Math.Sin(pi / 3), (v5.Y + v6.Y) / 2);
            Vector2 v7 = new Vector2(v4.X, v6.Y + (v5.X - v3.X) / Math.Tan(pi / 3));
            Vector2 v9 = new Vector2(-v7.X, v7.Y);
            Vector2 v10 = new Vector2(-v6.X, v6.Y);
            Vector2 v11 = new Vector2(-v5.X, v5.Y);
            Vector2 v12 = new Vector2(-v4.X, v4.Y);
            Vector2 v13 = new Vector2(-v3.X, v3.Y);
            Vector2 v14 = new Vector2(-v2.X, v2.Y);
            Vector2 v15 = new Vector2(-v1.X, v1.Y);
            Vector2 v16 = new Vector2(-dcon / 2, v15.Y);
            Vector2 v17 = new Vector2(v16.X, v9.Y + lccb);
            Vector2 v18 = new Vector2(-dccb / 2, v17.Y);
            Vector2 v19 = new Vector2(v18.X, v9.Y);
            Vector2 v20 = new Vector2(-v19.X, v19.Y);
            Vector2 v21 = new Vector2(-v18.X, v18.Y);
            Vector2 v22 = new Vector2(-v17.X, v17.Y);
            Vector2 v23 = new Vector2(-v16.X, v16.Y);
            Vector2 v24 = new Vector2(0, 2);
            Vector2 v25 = new Vector2(0, -oal - 2);
            Vector2 v26 = new Vector2(v6.X + 5, v6.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v8, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v8 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v7 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v10 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v10, v11 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v11, v12 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v9, v13 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v13, v14 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v14, v15 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v15, v1 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v14, v2 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line17 = { v23, v22 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
            Vector2[] Line18 = { v21, v20 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v24, v25 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v18, v19 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v16, v17 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v18, v21 };
            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
            Line Line23 = new Line(v6, v5);
            Line Line24 = new Line(v6, v26);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v18, v19), -offset - (v18.X - v11.X), 270, dimensionStyle);
            dim1.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v10, v6), -offset * 2, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v10, v11), -offset * 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v6), offset * 2 + (v6.X - v1.X) / 2, 270, dimensionStyle);
            dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v16, v23), offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v1, v15), offset * 2, 0, dimensionStyle);
            dim8.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v3, v13), offset * 3 + v1.Y - v3.Y, 0, dimensionStyle);
            dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v19, v20), -offset - v7.Y + v6.Y, 0, dimensionStyle);
            dim10.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            Angular2LineDimension angdim11 = new Angular2LineDimension(Line24, Line23, offset, dimensionStyle);
            angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v1, v2), offset + v3.X - v2.X, 270, dimensionStyle);
            dim12.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim12);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void FaceMillingCutter(Dictionary<string, Object> data)  //面铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sbd = Convert.ToDouble(data["bd"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sbd < 30 && soal < 62.25)
                {
                    scale = 4.0;
                }
                else if (sbd < 54 && soal < 83)
                {
                    scale = 3.0;
                }
                else if (sbd < 101 && soal < 124.5)
                {
                    scale = 2.0;
                }
                else if (sbd < 148 && soal < 166)
                {
                    scale = 1.5;
                }
                else if (sbd < 242 && soal < 249)
                {
                    scale = 1.0;
                }
                else if (sbd < 336 && soal < 332)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dcx = dc + apmx * 2 / Math.Tan(kapr);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub);
            Vector2 v3 = new Vector2(bd / 2, v2.Y);
            Vector2 v5 = new Vector2(dcx / 2, -oal + apmx);
            Vector2 v9 = new Vector2(v5.X - apmx, v5.Y + v5.X - dc / 2);
            Vector2 v4 = new Vector2(v3.X, -(dcx - dc) * v3.X / 2 / apmx + v5.Y + (dcx - dc) * v5.X / 2 / apmx);
            Vector2 v6 = new Vector2(dc / 2, -oal);
            Vector2 v8 = new Vector2(v6.X * 2 - v5.X, (v6.Y + v9.Y) / 2);
            Vector2 v7 = new Vector2(v4.X - (dcx - dc) / 2, v4.Y - apmx);
            Vector2 v10 = new Vector2(dccb / 2, v7.Y);
            Vector2 v11 = new Vector2(v10.X, v10.Y + lccb);
            Vector2 v12 = new Vector2(dcon / 2, v11.Y);
            Vector2 v13 = new Vector2(v12.X, v1.Y);
            Vector2 v14 = new Vector2(-v13.X, v13.Y);
            Vector2 v15 = new Vector2(-v12.X, v12.Y);
            Vector2 v16 = new Vector2(-v11.X, v11.Y);
            Vector2 v17 = new Vector2(-v10.X, v10.Y);
            Vector2 v18 = new Vector2(-v7.X, v7.Y);
            Vector2 v19 = new Vector2(-v6.X, v6.Y);
            Vector2 v20 = new Vector2(-v5.X, v5.Y);
            Vector2 v21 = new Vector2(-v4.X, v4.Y);
            Vector2 v22 = new Vector2(-v3.X, v3.Y);
            Vector2 v23 = new Vector2(-v2.X, v2.Y);
            Vector2 v24 = new Vector2(-v1.X, v1.Y);
            Vector2 v25 = new Vector2(0, 2);
            Vector2 v26 = new Vector2(0, -oal - 2);
            Vector2 v27 = new Vector2(v5.X, v6.Y);
            Vector2 v28 = new Vector2((v21.Y - v8.Y + 2 * apmx * v8.X / (dcx - dc)) * (dcx - dc) / 2 / apmx, v21.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v9, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v8 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v7, v18 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v18, v19 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v19, v20 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v20, v21 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v21, v18 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v21, v22 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v22, v3 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v23, v24 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v24, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v10, v11 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
            Vector2[] Line18 = { v11, v16 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v25, v26 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v16, v17 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v12, v13 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v14, v15 };
            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
            Line Line23 = new Line(v6, v5);
            Line Line24 = new Line(v6, v27);
            Vector2[] Line25 = { v21, v28 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v16, v17), -offset - (v17.X - v20.X), 270, dimensionStyle);
            dim1.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v19, v6), -offset * 2, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v5, v6), offset + (v5.X - v6.X) / 2, 270, dimensionStyle);
            dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v6), offset * 3 + v5.X - (v1.X + v6.X) / 2, 270, dimensionStyle);
            dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v20, v5), -offset * 3 - v5.Y + v6.Y, 0, dimensionStyle);
            dim5.UserText = "DCX = " + Math.Round(dcx / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v13, v14), offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v1, v24), offset * 2, 0, dimensionStyle);
            dim8.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v3, v22), offset * 3 + v1.Y - v3.Y, 0, dimensionStyle);
            dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v17, v10), -offset - v7.Y + v6.Y, 0, dimensionStyle);
            dim10.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            Angular2LineDimension angdim11 = new Angular2LineDimension(Line24, Line23, offset * 2 + (v5.X - v6.X) / 2, dimensionStyle);
            angdim11.UserText = "KAPR = " + Math.Round(kapr / pi * 180, 2) + "°";
            dxf.AddEntity(angdim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v1, v2), offset + v3.X - v2.X, 270, dimensionStyle);
            dim12.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim12);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void PlainMillingCutter(Dictionary<string, Object> data)  //圆柱形铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 30 && soal < 64.75)
                {
                    scale = 4.0;
                }
                else if (sdc < 54 && soal < 86.3)
                {
                    scale = 3.0;
                }
                else if (sdc < 101 && soal < 129.5)
                {
                    scale = 2.0;
                }
                else if (sdc < 148 && soal < 172.6)
                {
                    scale = 1.5;
                }
                else if (sdc < 242 && soal < 259)
                {
                    scale = 1.0;
                }
                else if (sdc < 336 && soal < 345.3)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double cwn = Convert.ToDouble(data["cwn"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub);
            Vector2 v3 = new Vector2(bd / 2, v2.Y);
            Vector2 v4 = new Vector2(v3.X, v3.Y - (oal - hhub - cwn) / 2);
            Vector2 v5 = new Vector2(dc / 2, v4.Y);
            Vector2 v6 = new Vector2(v5.X, v5.Y - cwn);
            Vector2 v7 = new Vector2(v4.X, v6.Y);
            Vector2 v8 = new Vector2(v7.X, -oal);
            Vector2 v9 = new Vector2(-v8.X, v8.Y);
            Vector2 v10 = new Vector2(-v7.X, v7.Y);
            Vector2 v11 = new Vector2(-v6.X, v6.Y);
            Vector2 v12 = new Vector2(-v5.X, v5.Y);
            Vector2 v13 = new Vector2(-v4.X, v4.Y);
            Vector2 v14 = new Vector2(-v3.X, v3.Y);
            Vector2 v15 = new Vector2(-v2.X, v2.Y);
            Vector2 v16 = new Vector2(-v1.X, v1.Y);
            Vector2 v17 = new Vector2(-dcon / 2, v16.Y);
            Vector2 v18 = new Vector2(v17.X, -oal + lccb);
            Vector2 v19 = new Vector2(-dccb / 2, v18.Y);
            Vector2 v20 = new Vector2(v19.X, -oal);
            Vector2 v21 = new Vector2(-v20.X, v20.Y);
            Vector2 v22 = new Vector2(-v19.X, v19.Y);
            Vector2 v23 = new Vector2(-v18.X, v18.Y);
            Vector2 v24 = new Vector2(-v17.X, v17.Y);
            Vector2 v25 = new Vector2(0, 2);
            Vector2 v26 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v8 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v14 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v10, v11 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v11, v12 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v12, v13 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v14, v15 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v15, v16 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v16, v1 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v2 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
            Vector2[] Line18 = { v19, v20 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v25, v26 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v21, v22 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v23, v24 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v19, v22 };
            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.4 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.4 * scale, hline2, contour, 0.5);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v21, v22), offset + v6.X - v21.X, 270, dimensionStyle);
            dim1.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v6), -offset * 3 - v7.Y + v8.Y, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v5, v6), offset * 2, 270, dimensionStyle);
            dim3.UserText = "CWN = " + Math.Round(cwn / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v8), offset * 3 + v6.X - (v8.X + v1.X) / 2, 270, dimensionStyle);
            dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v24), offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v1, v16), offset * 2, 0, dimensionStyle);
            dim8.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v8, v9), -offset * 2, 0, dimensionStyle);
            dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v21, v20), -offset, 0, dimensionStyle);
            dim10.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v1, v2), offset + v6.X - v2.X, 270, dimensionStyle);
            dim12.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v2, v3), offset - v2.Y, 0, dimensionStyle);
            dim7.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim7);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ShellMillingCutter(Dictionary<string, Object> data)  //套式立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 30 && soal < 64.75)
                {
                    scale = 4.0;
                }
                else if (sdc < 54 && soal < 86.3)
                {
                    scale = 3.0;
                }
                else if (sdc < 101 && soal < 129.5)
                {
                    scale = 2.0;
                }
                else if (sdc < 148 && soal < 172.6)
                {
                    scale = 1.5;
                }
                else if (sdc < 242 && soal < 259)
                {
                    scale = 1.0;
                }
                else if (sdc < 336 && soal < 345.3)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double cwn = Convert.ToDouble(data["cwn"]) * scale;
            double cdx = Convert.ToDouble(data["cdx"]) * scale;
            double az = Convert.ToDouble(data["az"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub);
            Vector2 v3 = new Vector2(bd / 2, v2.Y);
            Vector2 v4 = new Vector2(v3.X, -oal - az + cwn);
            Vector2 v5 = new Vector2(dc / 2, v4.Y);
            Vector2 v6 = new Vector2(v5.X, -oal - az);
            Vector2 v7 = new Vector2(v6.X - cdx, v6.Y);
            Vector2 v8 = new Vector2(v3.X, -oal);
            Vector2 v9 = new Vector2(-v8.X, v8.Y);
            Vector2 v10 = new Vector2(-v7.X, v7.Y);
            Vector2 v11 = new Vector2(-v6.X, v6.Y);
            Vector2 v12 = new Vector2(-v5.X, v5.Y);
            Vector2 v13 = new Vector2(-v4.X, v4.Y);
            Vector2 v14 = new Vector2(-v3.X, v3.Y);
            Vector2 v15 = new Vector2(-v2.X, v2.Y);
            Vector2 v16 = new Vector2(-v1.X, v1.Y);
            Vector2 v17 = new Vector2(-dcon / 2, v16.Y);
            Vector2 v18 = new Vector2(v17.X, -oal + lccb);
            Vector2 v19 = new Vector2(-dccb / 2, v18.Y);
            Vector2 v20 = new Vector2(v19.X, -oal);
            Vector2 v21 = new Vector2(-v20.X, v20.Y);
            Vector2 v22 = new Vector2(-v19.X, v19.Y);
            Vector2 v23 = new Vector2(-v18.X, v18.Y);
            Vector2 v24 = new Vector2(-v17.X, v17.Y);
            Vector2 v25 = new Vector2(0, 2);
            Vector2 v26 = new Vector2(0, -oal - 2);
            Vector2 v27 = new Vector2(v7.X, v8.Y);
            Vector2 v28 = new Vector2(-v27.X, v27.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v8 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v27 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v8 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v10, v11 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v11, v12 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v12, v13 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v28, v10 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v9, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v3 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
            Vector2[] Line18 = { v19, v20 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v25, v26 };
            fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
            Vector2[] Line20 = { v21, v22 };
            fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
            Vector2[] Line21 = { v23, v24 };
            fun.drawPlinetype(dxf, Line21, 0.15, refin, Linetype.Dashed);
            Vector2[] Line22 = { v19, v22 };
            fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.4 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v28));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.4 * scale, hline2, contour, 0.5);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v21, v22), offset + v6.X - v21.X, 270, dimensionStyle);
            dim1.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v6), -offset * 3 - v7.Y + v8.Y, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v5, v6), offset * 2, 270, dimensionStyle);
            dim3.UserText = "CWN = " + Math.Round(cwn / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v8), offset * 3 + v6.X - (v8.X + v1.X) / 2, 270, dimensionStyle);
            dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v17, v24), offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v1, v16), offset * 2, 0, dimensionStyle);
            dim8.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v8, v9), -offset * 2, 0, dimensionStyle);
            dim9.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v21, v20), -offset, 0, dimensionStyle);
            dim10.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v1, v2), offset + v6.X - v2.X, 270, dimensionStyle);
            dim12.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v2, v3), offset - v2.Y, 0, dimensionStyle);
            dim7.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim7);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void FullSideSlotMillingCutter(Dictionary<string, Object> data)  //三面刃铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dist = Convert.ToDouble(data["dist"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if ((oal - hhub - cw + dist * 2) == 0)
            {
                Vector2 v1 = new Vector2(dhub / 2, 0);
                Vector2 v2 = new Vector2(v1.X, -hhub + dist);
                Vector2 v3 = new Vector2(dc / 2, v2.Y);
                Vector2 v4 = new Vector2(v3.X, -oal - dist);
                Vector2 v5 = new Vector2(v2.X, v4.Y);
                Vector2 v6 = new Vector2(v5.X, v5.Y + dist);
                Vector2 v7 = new Vector2(bd / 2, v6.Y);
                Vector2 v8 = new Vector2(v7.X, -hhub);
                Vector2 v9 = new Vector2(v2.X, v8.Y);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(-dcon / 2, 0);
                Vector2 v20 = new Vector2(v19.X, -oal);
                Vector2 v21 = new Vector2(-v20.X, v20.Y);
                Vector2 v22 = new Vector2(-v19.X, v19.Y);
                Vector2 v23 = new Vector2(0, 2);
                Vector2 v24 = new Vector2(0, -oal - dist - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v9 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v12, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v14 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v14, v15 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v19, v20 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v21, v22 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v23, v24 };
                fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset, 270, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v15), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v1, v9), offset + v3.X - v1.X, 270, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v4.X - (v7.X + v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v19, v22), offset, 0, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v18, v1), offset * 2, 0, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v12, v7), -offset - dist, 0, dimensionStyle);
                dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v3, v2), offset + v1.Y - v2.Y, 0, dimensionStyle);
                dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
                dxf.AddEntity(dim9);
            }
            if ((oal - hhub - cw + dist * 2) != 0)
            {
                Vector2 v1 = new Vector2(dhub / 2, 0);
                Vector2 v2 = new Vector2(v1.X, -hhub + dist);
                Vector2 v3 = new Vector2(dc / 2, v2.Y);
                Vector2 v4 = new Vector2(v3.X, -oal + hhub - dist);
                Vector2 v5 = new Vector2(v2.X, v4.Y);
                Vector2 v6 = new Vector2(v5.X, v5.Y + dist);
                Vector2 v7 = new Vector2(bd / 2, v6.Y);
                Vector2 v8 = new Vector2(v7.X, -hhub);
                Vector2 v9 = new Vector2(v2.X, v8.Y);
                Vector2 v10 = new Vector2(v1.X, -oal);
                Vector2 v11 = new Vector2(-v10.X, v10.Y);
                Vector2 v12 = new Vector2(-v9.X, v9.Y);
                Vector2 v13 = new Vector2(-v8.X, v8.Y);
                Vector2 v14 = new Vector2(-v7.X, v7.Y);
                Vector2 v15 = new Vector2(-v6.X, v6.Y);
                Vector2 v16 = new Vector2(-v5.X, v5.Y);
                Vector2 v17 = new Vector2(-v4.X, v4.Y);
                Vector2 v18 = new Vector2(-v3.X, v3.Y);
                Vector2 v19 = new Vector2(-v2.X, v2.Y);
                Vector2 v20 = new Vector2(-v1.X, v1.Y);
                Vector2 v21 = new Vector2(-dcon / 2, v20.Y);
                Vector2 v22 = new Vector2(v21.X, v11.Y);
                Vector2 v23 = new Vector2(-v22.X, v22.Y);
                Vector2 v24 = new Vector2(-v21.X, v21.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v9 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v10, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v14, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v13 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v14 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v15, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v10, v11 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v17, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v23, v24 };
                fun.drawPlinetype(dxf, Line15, 0.15,refin, Linetype.Dashed);
                Vector2[] Line16 = { v21, v22 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v25, v26 };
                fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
                Vector2[] Line18 = { v12, v20 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v20, v1 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset, 270, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v17), -offset * 2 - hhub + dist, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v1, v9), offset + v3.X - v1.X, 270, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 2 + v4.X - v1.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 0, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v20, v1), offset * 2, 0, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v14, v7), -offset - hhub, 0, dimensionStyle);
                dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v3, v2), offset + v1.Y - v2.Y, 0, dimensionStyle);
                dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
                dxf.AddEntity(dim9);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

           

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void HalfSideSlotMillingCutter(Dictionary<string, Object> data)  //两面刃铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dist = Convert.ToDouble(data["dist"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if ((oal - hhub - lu + dist) == 0)
            {
                Vector2 v1 = new Vector2(dhub / 2, 0);
                Vector2 v2 = new Vector2(bd / 2, -oal - dist + cw);
                Vector2 v3 = new Vector2(dc / 2, v2.Y);
                Vector2 v4 = new Vector2(v3.X, -oal - dist);
                Vector2 v5 = new Vector2(v1.X, v4.Y);
                Vector2 v6 = new Vector2(v5.X, v5.Y + dist);
                Vector2 v7 = new Vector2(bd / 2, v6.Y);
                Vector2 v8 = new Vector2(v7.X, -hhub);
                Vector2 v9 = new Vector2(v1.X, v8.Y);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(-dcon / 2, 0);
                Vector2 v20 = new Vector2(v19.X, -oal);
                Vector2 v21 = new Vector2(-v20.X, v20.Y);
                Vector2 v22 = new Vector2(-v19.X, v19.Y);
                Vector2 v23 = new Vector2(0, 2);
                Vector2 v24 = new Vector2(0, -oal - dist - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v9 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v12, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v14 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v14, v15 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v19, v20 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v21, v22 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v23, v24 };
                fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
                Vector2[] Line18 = { v11, v12 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset, 270, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v15), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v1, v9), offset + v3.X - v1.X, 270, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v4.X - (v7.X + v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v19, v22), offset, 0, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v18, v1), offset * 2, 0, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v12, v7), -offset - dist, 0, dimensionStyle);
                dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v3, v1), offset + v1.Y - (v1.Y + v3.Y) / 2, 0, dimensionStyle);
                dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v11, v15), -offset - (v11.X - v15.X) / 2, 270, dimensionStyle);
                dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim10);
            }
            if ((oal - hhub - lu + dist) != 0)
            {
                Vector2 v1 = new Vector2(dhub / 2, 0);
                Vector2 v2 = new Vector2(bd / 2, -oal + hhub - dist + cw);
                Vector2 v3 = new Vector2(dc / 2, v2.Y);
                Vector2 v4 = new Vector2(v3.X, -oal + hhub - dist);
                Vector2 v5 = new Vector2(v1.X, v4.Y);
                Vector2 v6 = new Vector2(v5.X, v5.Y + dist);
                Vector2 v7 = new Vector2(bd / 2, v6.Y);
                Vector2 v8 = new Vector2(v7.X, -hhub);
                Vector2 v9 = new Vector2(v1.X, v8.Y);
                Vector2 v10 = new Vector2(v1.X, -oal);
                Vector2 v11 = new Vector2(-v10.X, v10.Y);
                Vector2 v12 = new Vector2(-v9.X, v9.Y);
                Vector2 v13 = new Vector2(-v8.X, v8.Y);
                Vector2 v14 = new Vector2(-v7.X, v7.Y);
                Vector2 v15 = new Vector2(-v6.X, v6.Y);
                Vector2 v16 = new Vector2(-v5.X, v5.Y);
                Vector2 v17 = new Vector2(-v4.X, v4.Y);
                Vector2 v18 = new Vector2(-v3.X, v3.Y);
                Vector2 v19 = new Vector2(-v2.X, v2.Y);
                Vector2 v20 = new Vector2(-v1.X, v1.Y);
                Vector2 v21 = new Vector2(-dcon / 2, v20.Y);
                Vector2 v22 = new Vector2(v21.X, v11.Y);
                Vector2 v23 = new Vector2(-v22.X, v22.Y);
                Vector2 v24 = new Vector2(-v21.X, v21.Y);
                Vector2 v25 = new Vector2(0, 2);
                Vector2 v26 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v9 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v10, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v14, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v13 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v14 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v15, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v10, v11 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v16, v17 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v17, v18 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v18, v19 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v23, v24 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v21, v22 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v25, v26 };
                fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
                Vector2[] Line18 = { v12, v20 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v20, v1 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset, 270, dimensionStyle);
                dim1.UserText = "CW = " + Math.Round(cw / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v4, v17), -offset * 2 - hhub + dist, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v1, v9), offset + v3.X - v1.X, 270, dimensionStyle);
                dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 2 + v4.X - v1.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 0, dimensionStyle);
                dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v20, v1), offset * 2, 0, dimensionStyle);
                dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v14, v7), -offset - hhub, 0, dimensionStyle);
                dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v3, v1), offset + v1.Y - (v1.Y + v3.Y) / 2, 0, dimensionStyle);
                dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v13, v17), -offset - (v13.X - v17.X) / 2, 270, dimensionStyle);
                dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
                dxf.AddEntity(dim10);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

           
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void FullSideProfileSlotMillingCutter(Dictionary<string, Object> data)  //三面刃轮廓铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cwn = Convert.ToDouble(data["cwn"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dist = Convert.ToDouble(data["dist"]) * scale;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub + dist);
            Vector2 v3 = new Vector2(dc / 2, v2.Y);
            Vector2 v4 = new Vector2(v3.X, -oal + hhub - dist + (cwn - dist * 2) / 3);
            Vector2 v5 = new Vector2(v4.X - (cwn - dist * 2) / 3 - Math.Sqrt((cwn - dist * 2) * (cwn - dist * 2) / 9 - (cwn - dist * 5) * (cwn - dist * 5) / 9), -oal + hhub);
            Vector2 v6 = new Vector2(v1.X, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -oal);
            Vector2 v8 = new Vector2(bd / 2, v5.Y);
            Vector2 v9 = new Vector2(v8.X, -hhub);
            Vector2 v10 = new Vector2(v6.X, v9.Y);
            Vector2 v11 = new Vector2(-v10.X, v10.Y);
            Vector2 v12 = new Vector2(-v9.X, v9.Y);
            Vector2 v13 = new Vector2(-v8.X, v8.Y);
            Vector2 v14 = new Vector2(-v6.X, v6.Y);
            Vector2 v15 = new Vector2(-v7.X, v7.Y);
            Vector2 v16 = new Vector2(-v5.X, v5.Y);
            Vector2 v17 = new Vector2(-v4.X, v4.Y);
            Vector2 v18 = new Vector2(-v3.X, v3.Y);
            Vector2 v19 = new Vector2(-v2.X, v2.Y);
            Vector2 v20 = new Vector2(-v1.X, v1.Y);
            Vector2 v21 = new Vector2(-dcon / 2, v20.Y);
            Vector2 v22 = new Vector2(v21.X, v7.Y);
            Vector2 v23 = new Vector2(-v22.X, v22.Y);
            Vector2 v24 = new Vector2(-v21.X, v21.Y);
            Vector2 v25 = new Vector2(0, 2);
            Vector2 v26 = new Vector2(0, -oal - 2);
            double r = (cwn - dist * 2) / 3;
            double l = 2 * Math.Sqrt((v4.Y - v5.Y) * (v4.Y - v5.Y) / 4 + (v4.X - v5.X) * (v4.X - v5.X) / 4);
            double h = r - Math.Sqrt(r * r - l * l / 4);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v10 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v5));
            Arc4.Vertexes.Add(new LwPolylineVertex(v4));
            Arc4.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc4, 0.3, contour);
            Vector2[] Line5 = { v7, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v13, v8 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v12 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v12, v13 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v15, v14 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v15, v7 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            LwPolyline Arc12 = new LwPolyline();
            Arc12.Vertexes.Add(new LwPolylineVertex(v17));
            Arc12.Vertexes.Add(new LwPolylineVertex(v16));
            Arc12.Vertexes[0].Bulge = 2 * h / l;
            fun.PolyFill(dxf, Arc12, 0.3, contour);
            Vector2[] Line13 = { v17, v18 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v18, v19 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v23, v24 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            Vector2[] Line16 = { v21, v22 };
            fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
            Vector2[] Line17 = { v25, v26 };
            fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
            Vector2[] Line18 = { v11, v20 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v20, v1 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes[2].Bulge = -2 * h / l;
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 0.3, hline1, harc1, contour);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly2.Vertexes[2].Bulge = 2 * h / l;
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 0.3, hline2, harc2, contour);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, new Vector2(v3.X - r, v4.Y - r)), offset + r / 2, 270, dimensionStyle);
            dim1.UserText = "CWN = " + Math.Round(cwn / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v4, v17), -offset * 2 - v17.Y + v15.Y, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v1, v10), offset + v3.X - v1.X, 270, dimensionStyle);
            dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v4.X - v1.X, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v21, v24), offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v20, v1), offset * 2, 0, dimensionStyle);
            dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v13, v8), -offset - hhub, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v3, v2), offset + v1.Y - v2.Y, 0, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void FullSideAngularSlotMillingCutter(Dictionary<string, Object> data)  //三面刃单角铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);



            //作图
            //参数
            double pi = Math.PI;
            double soal = Convert.ToDouble(data["oal"]);
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39 && soal < 90)
                {
                    scale = 4.0;
                }
                else if (sdc < 52 && soal < 120)
                {
                    scale = 3.0;
                }
                else if (sdc < 78 && soal < 180)
                {
                    scale = 2.0;
                }
                else if (sdc < 104 && soal < 240)
                {
                    scale = 1.5;
                }
                else if (sdc < 156 && soal < 360)
                {
                    scale = 1.0;
                }
                else if (sdc < 208 && soal < 480)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dhub = Convert.ToDouble(data["dhub"]) * scale;
            double cwn = Convert.ToDouble(data["cwn"]) * scale;
            double hhub = Convert.ToDouble(data["hhub"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dist = Convert.ToDouble(data["dist"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]) * pi / 180;
            double cdx = (dc - dhub) / 2;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dhub / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -hhub + dist);
            Vector2 v3 = new Vector2(dc / 2, v2.Y);
            Vector2 v4 = new Vector2(v3.X - cwn / Math.Tan(kapr), v3.Y - cwn);
            Vector2 v5 = new Vector2(v2.X, v4.Y);
            Vector2 v6 = new Vector2(v5.X, v5.Y + dist);
            Vector2 v8 = new Vector2(bd / 2, -hhub);
            Vector2 v7 = new Vector2(v8.X - (cwn - dist * 2) / Math.Tan(kapr), -oal + hhub);
            Vector2 v9 = new Vector2(v2.X, v8.Y);
            Vector2 v10 = new Vector2(v1.X, -oal);
            Vector2 v11 = new Vector2(-v10.X, v10.Y);
            Vector2 v12 = new Vector2(-v9.X, v9.Y);
            Vector2 v13 = new Vector2(-v8.X, v8.Y);
            Vector2 v14 = new Vector2(-v7.X, v7.Y);
            Vector2 v15 = new Vector2(-v6.X, v6.Y);
            Vector2 v16 = new Vector2(-v5.X, v5.Y);
            Vector2 v17 = new Vector2(-v4.X, v4.Y);
            Vector2 v18 = new Vector2(-v3.X, v3.Y);
            Vector2 v19 = new Vector2(-v2.X, v2.Y);
            Vector2 v20 = new Vector2(-v1.X, v1.Y);
            Vector2 v21 = new Vector2(-dcon / 2, v20.Y);
            Vector2 v22 = new Vector2(v21.X, v11.Y);
            Vector2 v23 = new Vector2(-v22.X, v22.Y);
            Vector2 v24 = new Vector2(-v21.X, v21.Y);
            Vector2 v25 = new Vector2(0, 2);
            Vector2 v26 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v9 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v10, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v14, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v13 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v13, v14 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v15, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v10, v11 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v16, v17 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v17, v18 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v18, v19 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v23, v24 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            Vector2[] Line16 = { v21, v22 };
            fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
            Vector2[] Line17 = { v25, v26 };
            fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
            Vector2[] Line18 = { v12, v20 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v20, v1 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 0.5 * scale, hline1, contour, 0.5);
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 0.5 * scale, hline2, contour, 0.5);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v3, v4), offset + (v3.X - v4.X) / 2, 270, dimensionStyle);
            dim1.UserText = "CWN = " + Math.Round(cwn / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v3, v18), offset * 3 + hhub - dist, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v1, v9), offset + v3.X - v1.X, 270, dimensionStyle);
            dim3.UserText = "HHUB = " + Math.Round(hhub / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 2 + v3.X - v1.X, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v22, v23), -offset, 0, dimensionStyle);
            dim6.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v20, v1), offset, 0, dimensionStyle);
            dim7.UserText = "DHUB = " + Math.Round(dhub / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v13, v8), offset * 2 + hhub, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v3, v2), offset + v1.Y - v2.Y, 0, dimensionStyle);
            dim9.UserText = "CDX = " + Math.Round(cdx / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

           

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SawBladeSlittingCutter(Dictionary<string, Object> data)    //锯片/切口铣刀
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            double sdc = Convert.ToDouble(data["dc"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (sdc < 39)
                {
                    scale = 4.0;
                }
                else if (sdc < 52)
                {
                    scale = 3.0;
                }
                else if (sdc < 78)
                {
                    scale = 2.0;
                }
                else if (sdc < 104)
                {
                    scale = 1.5;
                }
                else if (sdc < 156)
                {
                    scale = 1.0;
                }
                else if (sdc < 208)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double dah = Convert.ToDouble(data["dah"]) * scale;
            double dbhc = Convert.ToDouble(data["dbhc"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(-19, 0);
            Vector2 v2 = new Vector2(v1.X, dbhc / 2);
            Vector2 v3 = new Vector2(v1.X + dbhc / 2, 0);
            Vector2 v4 = new Vector2(v2.X, -v2.Y);
            Vector2 v5 = new Vector2(v1.X - dbhc / 2, 0);
            Vector2 v6 = new Vector2(v1.X, dc / 2 + 2);
            Vector2 v7 = new Vector2(v1.X + dc / 2 + 2, 0);
            Vector2 v8 = new Vector2(v6.X, -v6.Y);
            Vector2 v9 = new Vector2(v1.X - dc / 2 - 2, 0);
            //左视图
            Vector2 v10 = new Vector2(171 - oal / 2, v6.Y);
            Vector2 v11 = new Vector2(171 + oal / 2, v10.Y);
            Vector2 v12 = new Vector2(v11.X, -v11.Y);
            Vector2 v13 = new Vector2(v10.X, -v10.Y);
            Vector2 v14 = new Vector2(v13.X, v4.Y - dah / 2);
            Vector2 v15 = new Vector2(v12.X, v14.Y);
            Vector2 v16 = new Vector2(v15.X + 2, v4.Y);
            Vector2 v17 = new Vector2(v14.X - 2, v4.Y);
            Vector2 v18 = new Vector2(v14.X, v4.Y + dah / 2);
            Vector2 v19 = new Vector2(v15.X, v18.Y);
            Vector2 v20 = new Vector2(v19.X, -dcon / 2);
            Vector2 v21 = new Vector2(v18.X, v20.Y);
            Vector2 v22 = new Vector2(v17.X, 0);
            Vector2 v23 = new Vector2(v16.X, 0);
            Vector2 v24 = new Vector2(v20.X, -v20.Y);
            Vector2 v25 = new Vector2(v21.X, -v21.Y);
            Vector2 v26 = new Vector2(v18.X, -v18.Y);
            Vector2 v27 = new Vector2(v19.X, -v19.Y);
            Vector2 v28 = new Vector2(v16.X, -v16.Y);
            Vector2 v29 = new Vector2(v17.X, -v17.Y);
            Vector2 v30 = new Vector2(v14.X, -v14.Y);
            Vector2 v31 = new Vector2(v15.X, -v15.Y);
            //线段
            //主视图
            fun.drawcircle(dxf, v1, dcon / 2, 0.3, contour);
            fun.drawcircle(dxf, v1, dc / 2, 0.3, contour);
            if (dbhc != 0)
            {
                fun.drawcircle(dxf, v1, dbhc / 2, 0.15, refin);
                fun.drawcircle(dxf, v2, dah / 2, 0.3, contour);
                fun.drawcircle(dxf, v3, dah / 2, 0.3, contour);
                fun.drawcircle(dxf, v4, dah / 2, 0.3, contour);
                fun.drawcircle(dxf, v5, dah / 2, 0.3, contour);
            }
            //侧视图
            Vector2[] Line1 = { v10, v11 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v11, v12 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v12, v13 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v13, v10 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line6 = { v16, v17 };
            fun.drawPlinetype(dxf, Line6, 0.15, center, Linetype.Center);
            Vector2[] Line8 = { v20, v21 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v22, v23 };
            fun.drawPlinetype(dxf, Line9, 0.15, center, Linetype.Center);
            Vector2[] Line10 = { v24, v25 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line12 = { v28, v29 };
            fun.drawPlinetype(dxf, Line12, 0.15, center, Linetype.Center);
            if (dbhc != 0)
            {
                Vector2[] Line5 = { v14, v15 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line7 = { v18, v19 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line11 = { v26, v27 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line13 = { v30, v31 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
            }
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v31));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v30));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            if (dbhc != 0)
            {
                fun.hatchsuboflinew(dxf, htype1, hnumst1, 45, 5, hline1, hatching, 0.15);
            }
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v26));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v27));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            if (dbhc != 0)
            {
                fun.hatchsuboflinew(dxf, htype2, hnumst2, 45, 5, hline2, hatching, 0.15);
            }
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v19));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            if (dbhc != 0)
            {
                fun.hatchsuboflinew(dxf, htype3, hnumst3, 45, 5, hline3, hatching, 0.15);
            }
            LwPolyline hatchpoly4 = new LwPolyline();
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly4.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly4.IsClosed = true;
            String[] htype4 = new String[100];
            Line[] hline4 = new Line[100];
            int hnumst4 = hatchpoly4.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst4; i++)
            {
                htype4[i] = hatchpoly4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype4[i] == "Line")
                {
                    hline4[i] = (Line)hatchpoly4.Explode()[i];
                }
            }
            if (dbhc != 0)
            {
                fun.hatchsuboflinew(dxf, htype4, hnumst4, 45, 5, hline4, hatching, 0.15);
            }
            LwPolyline hatchpoly5 = new LwPolyline();
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v24));
            hatchpoly5.Vertexes.Add(new LwPolylineVertex(v25));
            hatchpoly5.IsClosed = true;
            String[] htype5 = new String[100];
            Line[] hline5 = new Line[100];
            int hnumst5 = hatchpoly5.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst5; i++)
            {
                htype5[i] = hatchpoly5.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype5[i] == "Line")
                {
                    hline5[i] = (Line)hatchpoly5.Explode()[i];
                }
            }
            if (dbhc == 0)
            {
                fun.hatchsuboflinew(dxf, htype5, hnumst5, 45, 5, hline5, hatching, 0.15);
            }
            LwPolyline hatchpoly6 = new LwPolyline();
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v20));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v21));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly6.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly6.IsClosed = true;
            String[] htype6 = new String[100];
            Line[] hline6 = new Line[100];
            int hnumst6 = hatchpoly6.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst6; i++)
            {
                htype6[i] = hatchpoly6.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype6[i] == "Line")
                {
                    hline6[i] = (Line)hatchpoly6.Explode()[i];
                }
            }
            if (dbhc == 0)
            {
                fun.hatchsuboflinew(dxf, htype6, hnumst6, 45, 5, hline6, hatching, 0.15);
            }
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0 / 2;
            double offset = 10;
            //线段尺寸标注
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(new Vector2(v1.X - dcon / 2, 0), new Vector2(v1.X + dcon / 2, 0)), -dc / 2 - offset, 0, dimensionStyle);
            dim2.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim2);
            if (dbhc != 0)
            {
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v5, v3), -offset * 2 - dc / 2, 0, dimensionStyle);
                dim3.UserText = "DBHC = " + Math.Round(dbhc / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(new Vector2(v3.X - dah / 2, 0), new Vector2(v3.X + dah / 2, 0)), -offset - dc / 2, 0, dimensionStyle);
                dim4.UserText = "DAH = " + Math.Round(dah / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v11, v10), offset, 0, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(new Vector2(v6.X, v6.Y - 2), new Vector2(v8.X, v8.Y + 2)), offset + dc / 2, 270, dimensionStyle);
            dim6.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim6);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(-210, 148.5));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}